<!doctype html>
<html lang="zh-cmn-Hans">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no"/>
    <meta name="renderer" content="webkit"/>
    <meta name="force-rendering" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <link rel="stylesheet" href="{{ url_for('static',filename='css/mdui.min.css') }}">
    <title>{% block title %}{% endblock %}</title>
  </head>
  <body class="mdui-appbar-with-toolbar mdui-theme-accent-blue mdui-theme-primary-blue mdui-theme-layout-auto padding-top">

    <div style="height: 50px; min-width: 250px;" class="mdui-appbar mdui-appbar-fixed mdui-color-white mdui-shadow-1">
      <div style="height: 50px;" class="mdui-toolbar mdui-color-white">
        <a href="javascript:;" class="mdui-btn mdui-btn-dense mdui-btn-icon mdui-ripple"><i class="mdui-icon material-icons">menu</i></a>
        <a id="m-title" href="javascript:;" class="mdui-typo-title">{% block main %}{% endblock %}</a>
        <div class="mdui-toolbar-spacer"></div>
        {% if data.account.uid == None %}
        <button class="mdui-btn mdui-btn-dense mdui-color-theme-accent mdui-ripple mdui-hidden-xs">登录</button>
        <button class="mdui-btn mdui-btn-dense mdui-btn-icon mdui-text-color-theme mdui-ripple mdui-hidden-sm-up"><i class="mdui-icon material-icons">insert_link</i></button>
        {% else %}
        <img class="mdui-img-circle" style="width: 28px; height: 28px;" src="http://q1.qlogo.cn/g?b=qq&nk={{data.account.head}}&s=640"/>
        {% endif %}
      </div>
    </div>

    <div id="inner" style="width: 100%;overflow: scroll;" class="mdui-p-b-0">
    {% block body %}

	  {% endblock %}
    </div>

    <script src="{{ url_for('static', filename='js/mdui.min.js') }}"></script>
    <script src="{{ url_for('static', filename='js/cookie.js') }}"></script>
    <script>
      function DeviceIden() {
          var sUserAgent = navigator.userAgent.toLowerCase();
          var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
          var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
          var bIsMidp = sUserAgent.match(/midp/i) == "midp";
          var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
          var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
          var bIsAndroid = sUserAgent.match(/android/i) == "android";
          var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
          var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
          if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
              return "phone";
          } else {
              return "computer";
          }
      }
      function CreateQRcode(D=null) {
        var path = window.location.pathname;
        var protocol = window.location.protocol;
        var port = window.location.port;
        if (D==null){
          var data = "data=" + protocol+ "://" + "{{data.ip}}" + ":" + port + path;
        }else{
          var data = "data=" + D
        }
        
        var xmlhttp;
        if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        } else {
            xmlhttp = new ActiveXObject('Microsoft.XMLHttp');
        }
        xmlhttp.onreadystatechange = function() {
            if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                var res = xmlhttp.responseText;
                alert(res);
            }
        }
        xmlhttp.open('POST', '/api/qrcode', true);
        xmlhttp.setRequestHeader( "Content-Type" , "application/x-www-form-urlencoded" );
        xmlhttp.send(data);
      }
      function AutoInnerHei(){
          var winHeight=0;
          if (window.innerHeight){
              winHeight = window.innerHeight;
          }
          else if ((document.body) && (document.body.clientHeight)){
              winHeight = document.body.clientHeight;
          }
          if (document.documentElement && document.documentElement.clientHeight){
              winHeight = document.documentElement.clientHeight;
          }
          winHeight = winHeight - 50;
          document.getElementById("inner").style.height = winHeight +"px";
      }
      AutoInnerHei();
      window.onresize = AutoInnerHei;

      var err = GetCookie('Error')[0];
      DeleteCookie('Error');
      if (err != null){
          mdui.snackbar({
              message: err,
              position: 'right-bottom'
          });
      }
    </script>
  </body>
</html>